package com.xqls.service.impl;

import com.xqls.biz.FluggasTableFieldBiz;
import com.xqls.dal.dao.FluggasBlockAdministrationDao;
import com.xqls.dal.model.FluggasBlockAdministration;
import com.xqls.dal.model.FluggasBlockAdministrationExample;
import com.xqls.dal.model.FluggasBlockAdministrationExample.Criteria;
import com.xqls.service.FluggasBlockAdministrationService;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by hdg on 2017/7/5.
 */
@Service
public class FluggasBlockAdministrationServiceImpl implements FluggasBlockAdministrationService {
    @Autowired
    FluggasBlockAdministrationDao FluggasBlockAdministrationDao;
    @Autowired
    FluggasTableFieldBiz FluggasTableFieldBiz;
    @Override
    public int countByExample(FluggasBlockAdministrationExample example) {
        return 0;
    }

    @Override
    public boolean deleteByExample(List<Integer> idList) {
        FluggasBlockAdministrationExample example = new FluggasBlockAdministrationExample();
        Criteria criteria= example.createCriteria();
        criteria.andFluggasIdIn(idList);
        return FluggasBlockAdministrationDao.deleteByExample(example)>0;
    }

    @Override
    public int deleteByPrimaryKey(Integer fluggasId) {
        return FluggasBlockAdministrationDao.deleteByPrimaryKey(fluggasId);
    }

    @Override
    public boolean insertDate(FluggasBlockAdministration record) {
        return FluggasBlockAdministrationDao.insert(record);
    }

    @Override
    public int insertSelective(FluggasBlockAdministration record) {
        return FluggasBlockAdministrationDao.insertSelective(record);
    }

    @Override
    public List<FluggasBlockAdministration> selectByExample(FluggasBlockAdministrationExample example) {
        return null;
    }

    @Override
    public FluggasBlockAdministration selectByPrimaryKey(Integer fluggasId) {
        return FluggasBlockAdministrationDao.selectByPrimaryKey(fluggasId);
    }

    @Override
    public int updateByExampleSelective(@Param("record") FluggasBlockAdministration record, @Param("example") FluggasBlockAdministrationExample example) {
        return 0;
    }

    @Override
    public int updateByExample(@Param("record") FluggasBlockAdministration record, @Param("example") FluggasBlockAdministrationExample example) {
        return 0;
    }

    @Override
    public int updateByPrimaryKeySelective(FluggasBlockAdministration record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(FluggasBlockAdministration record) {
        return FluggasBlockAdministrationDao.updateByPrimaryKey(record);
    }

    @Override
    public List<FluggasBlockAdministration> selectByblock(Map<String, Object> map) {
        return FluggasBlockAdministrationDao.selectByblock(map);
    }

    @Override
    public List<Map<String, Object>> selectAll(Map<String, Object> map) {
        List<Map<String, Object>> fluggasList = FluggasBlockAdministrationDao.selectAll(map);
        List<String> fieldList=new ArrayList<String>();
        String displayfield="";
            for (int i = 0; i < fluggasList.size(); i++) {
                displayfield = fluggasList.get(i).get("displayfield").toString();
                String displayfieldString = "";
                String[] str = displayfield.split(",");
                for (int j = 0; j < str.length; j++) {
                    fieldList.add(str[j]);
                }
                List<String> fieldChinese = FluggasTableFieldBiz.FieldChinese(fieldList);
                for (int j = 0; j < fieldChinese.size(); j++) {
                    displayfieldString += fieldChinese.get(j) + "，";
                }
                displayfieldString = displayfieldString.substring(0,displayfieldString.length()-1);
                fluggasList.get(i).put("displayfieldString",displayfieldString);
            }
        return fluggasList;
    }

    @Override
    public FluggasBlockAdministration selectByblockId(int blockId) {
        return FluggasBlockAdministrationDao.selectByblockId(blockId);
    }

    @Override
    public boolean addFiled(String filed, String type) {
        return FluggasBlockAdministrationDao.addFile(filed,type);
    }


}
